package ru.tennisworld.match.entities;

import jakarta.persistence.AttributeOverride;
import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import lombok.Data;
import ru.tennisworld.match.entities.base.BaseEntity;
import ru.tennisworld.match.entities.references.MatchStage;

import java.util.List;

@Data
@Entity
@Table(name = "MATCHES")
@AttributeOverride(name = "id", column = @Column(name = "MATCH_ID"))
@SequenceGenerator(name = "seq_gen", sequenceName = "MATCH_ID_SEQ", allocationSize = 1, initialValue = 1000)
public class Match extends BaseEntity {

    @ElementCollection
    @CollectionTable(name="MATCH_PLAYERS",
            joinColumns = @JoinColumn(name = "MATCH_ID"))
    @Column(name = "PLAYERS_IDS")
    private List<String> playersIds;

    @OneToOne
    @JoinColumn(name = "STAGE_ID")
    private MatchStage stage;

    @ElementCollection
    @CollectionTable(name="MATCH_WINNERS",
            joinColumns = @JoinColumn(name = "MATCH_ID"))
    @Column(name = "WINNER_IDS")
    private List<String> winnerIds;

    @Column(name = "RESULT")
    private String result;

    @Column(name = "IS_STARTED")
    private Boolean isStarted;

    @Column(name = "IS_FINISHED")
    private Boolean isFinished;


}
